package com.redepronik.negosysres.invfac.controller;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.event.ActionEvent;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.redepronik.negosys.invfac.entity.Caracteristica;
import com.redepronik.negosys.invfac.service.CaracteristicaService;

@Controller
@Scope("session")
public class CaracteristicaBean {

	@Autowired
	private CaracteristicaService caracteristicaService;

	private List<Caracteristica> listaCaracteristicas;
	private Caracteristica caracteristica;

	public CaracteristicaBean() {
		caracteristica = new Caracteristica();
	}

	public void actualizar(ActionEvent actionEvent) {
		caracteristicaService.actualizar(caracteristica);
	}

	public void eliminar(ActionEvent actionEvent) {
		caracteristicaService.eliminar(caracteristica);
	}

	public Caracteristica getCaracteristica() {
		return caracteristica;
	}

	public List<Caracteristica> getListaCaracteristicas() {
		return listaCaracteristicas;
	}

	@PostConstruct
	public void init() {
		listaCaracteristicas = caracteristicaService.obtener(null);
	}

	public void insertar(ActionEvent actionEvent) {
		listaCaracteristicas = caracteristicaService.insertar(caracteristica);
	}

	public void limpiarObjetos() {
		caracteristica = new Caracteristica();
	}

	public void setCaracteristica(Caracteristica caracteristica) {
		this.caracteristica = caracteristica;
	}

	public void setListaCaracteristicas(
			List<Caracteristica> listaCaracteristicas) {
		this.listaCaracteristicas = listaCaracteristicas;
	}
}
